package com.example.wishstar.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.example.wishstar.R;
import com.xujiaji.happybubble.BubbleDialog;

public class CustomOperateDialog extends BubbleDialog implements View.OnClickListener
{
    private ViewHolder mViewHolder;
    private OnClickCustomButtonListener mListener;

    public CustomOperateDialog(Context context, int resource)
    {
        super(context);
        calBar(true);
        setTransParentBackground();
        setPosition(Position.TOP);
        View rootView = LayoutInflater.from(context).inflate(resource, null);
        mViewHolder = new ViewHolder(rootView);
        addContentView(rootView);
        mViewHolder.textView1.setOnClickListener(this);
        mViewHolder.textView2.setOnClickListener(this);
    }

    @Override
    public void onClick(View v)
    {
        if (mListener != null)
        {
            mListener.onClick(((TextView)v).getText().toString());
        }
    }

    private static class ViewHolder
    {
        TextView textView1, textView2;
        public ViewHolder(View rootView)
        {
            textView1 = rootView.findViewById(R.id.xiugai);
            textView2 = rootView.findViewById(R.id.tuichu);
        }
    }

    public void setClickListener(OnClickCustomButtonListener l)
    {
        this.mListener = l;
    }

    public interface OnClickCustomButtonListener
    {
        void onClick(String str);
    }
}
